package com.xbq.exceleditor.ui.filechooser.media;

import android.webkit.MimeTypeMap;

import androidx.annotation.Keep;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Author: liaohaiping
 * Time: 2019-03-07
 * Description:
 */
@Keep
public enum FileTypeEnum {
    WORD("doc", "docx"),
    EXCEL("xls", "xlsx"),
    XLSX("xlsx"),
    PPT("ppt", "pptx"),
    PDF("pdf"),
    IMAGE("jpg", "jpeg", "png", "bmp"),
    TIFF("tiff");

    private List<String> fileExtensions;

    FileTypeEnum(String... fileExtensions) {
        this.fileExtensions = Arrays.asList(fileExtensions);
    }

    public List<String> getFileExtensions() {
        return fileExtensions;
    }

    public List<String> getFileExtensionWithDot() {
        List<String> arr = new ArrayList<>();
        for (String ext : fileExtensions) {
            arr.add("." + ext);
        }
        return arr;
    }


    public List<String> getMimeTypes() {
        List<String> arr = new ArrayList<>();
        for (String ext : fileExtensions) {
            String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
            arr.add(mimeType);
        }
        return arr;
    }
}
